package com.qiangua.lixin.qianguakeji;

import android.app.Activity;
import android.os.Bundle;
import android.widget.ListView;
import android.widget.SimpleAdapter;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * Created by Administrator on 2015/7/30 0030.
 */
public class TheActivity extends Activity {
    private ListView listView;
    private SimpleAdapter simpleAdapter;
    private List<Map<String,Object>>dataList;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.listview);
        listView = (ListView) findViewById(R.id.listview2);
//        listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
//
//            @Override
//            public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
//                switch (position) {
//                    case (7):
//                        Intent intent = new Intent(TheActivity.this,MainActivity.class);
//                        startActivity(intent);
//                        //finish();
//                        break;
//
//                }
//
//            }
//        });

        dataList = new ArrayList<Map<String, Object>>();
        simpleAdapter = new SimpleAdapter(TheActivity.this,getData(),R.layout.item,new String[]{"image_item","image_item1","textview1","textview2"},new int[]{R.id.image_item,R.id.image_item1,R.id.textview1,R.id.textview2});
       listView.setAdapter(simpleAdapter);



    }

    public List<Map<String,Object>> getData(){

        for(int i = 0;i<10;i++){
           // ImageView imageView = (ImageView) findViewById(R.id.image_item);
           // ImageView imageView1 = (ImageView) findViewById(R.id.image_item1);
           // TextView textView = (TextView) findViewById(R.id.textview1);
           // TextView textView1 = (TextView) findViewById(R.id.textview2);


            Map<String, Object> map = new HashMap<String,Object>();
            map.put("image_item",R.drawable.main_tab_ic_setting_selected);
            map.put("image_item1",R.drawable.ic_battery_100);
            map.put("textview1","设备名称"+i);
            map.put("textview2", "地点");

            dataList.add(map);
        }

        return dataList;
    }

}
